<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" type="image/png" href="assets/icon.png">

<title>测试和WEB数据格式转换工具</title>
</head>

<body>
<div class="lowB">本工具未支持low b浏览器，换个吧&#x1f644;</div><script>document.querySelector(".lowB").innerHTML=``;</script>

<script src="测试和WEB数据格式转换工具.js"></script>


<style>
body{
	word-wrap: break-word;
}
pre{
	white-space:pre-wrap;
}

.AreaFormat {
	position: relative;
	top:0;
	margin-top:20px;
}
</style>

<script src="https://xiangyuecn.github.io/BuildHTML/buildhtml.js"></script>
<script>
function el(cls){
	return document.querySelector(cls);
};

if(/^file:/.test(location.href)){
	FormatLog("浏览器直接打开的html文件，不加载演示数据，请手动操作",1);
}else{
	el(".AreaFormatFrom").innerHTML=BuildHTML(`
<select class="AreaFormatFromSelect" onchange="swapFrom()">
{{::
	;BuildHTMLArray('<option value="{fn:BuildHTMLArray.index+1}">{fn::AllowAccessFolder}/{fn::o}</option>',AllowAccessFiles)
}}
<\/select>`);
	var swapFrom=function(){
		var from=+el(".AreaFormatFromSelect").value-1;
		var path=AllowAccessFolder+"/"+AllowAccessFiles[from];
		FormatLog("【"+path+"】数据加载中...请稍后");
		var ajax=new XMLHttpRequest();
		ajax.open("GET",path.replace(/\(.+\)/,""));
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					var input=el(".AreaFormatInput");
					input.value=ajax.responseText;
					
					FormatLog(`成功加载【${path}】数据。
					<hr>
					<div>输入框中本来的提示信息：</div>
					<pre>${input.placeholder}</pre>
					
					<hr>
					<div class='initTest1'></div>
					
					<hr>
					<div class='initTest2'></div>
					
					<hr>
					<div class='initTest3'></div>`);//<script>
					
					TestClick("js",".initTest1");
					TestClick("jsonObject",".initTest2",460204);//选中 三亚 天涯
					TestClick("jsonArray",".initTest3",11);//选中 北京
				}else{
					FormatLog("【"+path+"】数据加载失败");
				}
			}
		}
		ajax.send();
	};
	swapFrom();
};
</script>

<!-- 加载打赏挂件 -->
<div class="DonateLogs"></div>
<div class="DonateView"></div>
<script crossorigin="anonymous" src="https://xiangyuecn.github.io/Recorder/assets/zdemo.widget.donate.js"></script>
<script>
DonateWidget({
	log:function(msg){var div=document.createElement("div");div.innerHTML=msg;document.querySelector(".DonateLogs").appendChild(div)}
	,mobElem:document.querySelector(".DonateView")
});
</script>

</body>
</html>
